<script>
  let current = "女";
</script>

性别：
<ul>
  {#each ["男", "女", "未知"] as sex, index}
    <!-- <li class={current === sex ? "selected" : ""}>{index}、{sex}</li> -->
    <li class:selected={current === sex}>{index}、{sex}</li>
  {/each}
</ul>

<style>
  .selected {
    background-color: pink;
  }
</style>
